package com.igs.parse.quartz;

import java.util.List;

import org.apache.log4j.Logger;

import com.loyin.model.DownloadUrl;

public class downLoadWebsite
{
	private static Logger log = Logger.getLogger(downLoadWebsite.class);

	public static void main(String[] args)
	{
		try
		{
			// 定时调度下载搜索到的目标网站
			DownloadUrl durl=new DownloadUrl();
			log.info("下载网站定时调度完成。。。。。。。。。。。");
			int i=0;
			int pageCount=10;
			while(true)
			{
				String pageSql=" ORDER BY id asc  LIMIT "+i+", "+pageCount+" ";
				List<DownloadUrl> dlist = (List<DownloadUrl>) durl.findBySql(durl.getClass(), 
				"select * from igs_downloadurl where isdownload=0 "+pageSql);
				if(dlist==null || dlist.size()==0)
					break;
				for(DownloadUrl du : dlist)
				{
					try
					{
						du = DowLoadHtml.downLoadHtml(du);
					}
					catch(Exception ex1)
					{
						log.error("下载一个网站异常", ex1);
					}
					du.save();
				}
				i=i+pageCount;
			}
			log.info("下载网站定时调度完成。。。。。。。。。。。");
		} catch (Exception ex)
		{
			log.error("下载网站异常", ex);
		}
	}
}
